package com.card323.crpg.io.swing;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JLabel;

import com.card323.crpg.hero.HeroStatusListener;

public class HeroStatusPane extends FadingPanel implements HeroStatusListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 554339015721757776L;

	/**
	 * Create the panel.
	 */
	JLabel lbl_hero_hp = new JLabel("max hp");
	JLabel lbl_hero_name = new JLabel("name");
	JLabel lbl_current_hp = new JLabel("current hp");

	public HeroStatusPane() {
		setPreferredSize(new Dimension(200, 200));
		add(lbl_hero_name);
		add(lbl_current_hp);

		JLabel lblNewLabel_1 = new JLabel("/");
		add(lblNewLabel_1);
		add(lbl_hero_hp);
	}

	public void on_name_changed(String old, String hero_name) {
		lbl_hero_name.setText(hero_name);
	}

	public void on_hp_changed(int old, int current) {
		lbl_hero_hp.setText(String.valueOf(current));

	}

	public void on_current_hp_changed(int old, int current_life) {
		lbl_current_hp.setText(String.valueOf(current_life));
		String fuhao = "+";
		Color c = Color.GREEN;
		int value = current_life - old;
		if (old >= current_life) {
			fuhao = "-";
			c = Color.RED;
			value = old - current_life;
		}
		this.p_msg(fuhao + value, c, lbl_current_hp.getX(), lbl_current_hp.getY()+20);

	}

}
